package com.xyht.medicine_management_system.modules.activity.controller;


import com.xyht.medicine_management_system.common.annotation.RequestPass;
import com.xyht.medicine_management_system.common.commonReturn.ResponseResult;
import com.xyht.medicine_management_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.medicine_management_system.modules.activity.entity.req.MmsActivityReq;
import com.xyht.medicine_management_system.modules.activity.service.MmsActivityService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 活动表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-11-29
 */
@RestController
@SecretBody
@RequestMapping("/activity")
public class MmsActivityController {
    @Resource
    private MmsActivityService mmsActivityService;

    @ApiModelProperty("添加活动")
    @PostMapping("/add")
    public ResponseResult addActivity(@RequestBody MmsActivityReq activityReq) {
        return mmsActivityService.addActivity(activityReq);
    }

    @ApiModelProperty("删除活动")
    @PostMapping("/del")
    public ResponseResult delActivity(@RequestBody MmsActivityReq activityReq) {
        return mmsActivityService.delActivity(activityReq);
    }

    @ApiModelProperty("修改活动")
    @PostMapping("/update")
    public ResponseResult updateActivity(@RequestBody MmsActivityReq activityReq) {
        return mmsActivityService.updateActivity(activityReq);
    }

    @ApiModelProperty("活动列表")
    @GetMapping("/list")
    @RequestPass
    public ResponseResult listActivity(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                       @RequestParam(value = "searchStr", required = false) String searchStr) {
        return mmsActivityService.listActivity(pageNum, pageSize, searchStr);
    }

    @ApiModelProperty("活动详情")
    @GetMapping("/detail")
    @RequestPass
    public ResponseResult activityDetail(@RequestParam("activityId") String activityId) {
        return mmsActivityService.activityDetail(activityId);
    }

}

